﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AssemblyProvider.Web;
using AbstraX.ServerInterfaces;
using SLControlProvider.Web;
using System.Diagnostics;
using AbstraX.Contracts;
using AbstraX.AssemblyInterfaces;
using SLControlProvider.Web.Entities;
using AbstraX;
using log4net;

namespace TestControlProvider
{
    class Program
    {
        private class Host : IDomainHostApplication
        {
            public IAssemblyProviderService AssemblyProviderService
            {
                get
                {
                    return new AssemblyProviderService();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }

            public string ImageEditorUrl
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }

            public string GetImageEditorUrl()
            {
                throw new NotImplementedException();
            }

            public List<IVSSolution> Solutions
            {
                get { throw new NotImplementedException(); }
            }

            public void SetStatus(string status)
            {
                throw new NotImplementedException();
            }

            public List<string> LatestStatus
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, IAbstraXProviderService> RegisteredServices
            {
                get { throw new NotImplementedException(); }
            }

            public AbstraX.Bindings.Interfaces.IBindingsTreeCache BindingsTreeCache
            {
                get { throw new NotImplementedException(); }
            }


            public AbstraX.Bindings.Interfaces.IBindingsGenerator BindingsGenerator
            {
                get { throw new NotImplementedException(); }
            }


            public Microsoft.Practices.Unity.IUnityContainer PipelineContainer
            {
                get { throw new NotImplementedException(); }
            }

            public void PostEventShowUI(string uiComponentURL, string parms)
            {
                throw new NotImplementedException();
            }

            public void PostEventBuildMessage(string message)
            {
                throw new NotImplementedException();
            }

            public void PostEventBuildComplete()
            {
                throw new NotImplementedException();
            }

            public void PostEventError(string errorMessage)
            {
                throw new NotImplementedException();
            }

            public void PostEventPercentComplete(float percentComplete)
            {
                throw new NotImplementedException();
            }

            public Queue<AbstraX.BuildUIQueueEntry> BuildUIQueue
            {
                get { throw new NotImplementedException(); }
            }

            public IEventsService EventsService
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }


            public bool FinishBuildWithDefaults
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }


            public void PostEventShowUI(string uiComponentURL, string parms, IBuildUIDaemon buildUIDaemon, TimeSpan waitTimeout)
            {
                throw new NotImplementedException();
            }

            public void ClearEventQueue()
            {
                throw new NotImplementedException();
            }

            public IPipelineService PipelineService
            {
                get { throw new NotImplementedException(); }
            }


            public Dictionary<string, ICodeTemplate> ProjectGroupTemplates
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, ICodeTemplate> ProjectTemplates
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, ICodeTemplate> ItemTemplates
            {
                get { throw new NotImplementedException(); }
            }


            public Dictionary<string, IBuildFilter> BuildFilters
            {
                get { throw new NotImplementedException(); }
            }


            public List<IProgrammingLanguage> AvailableLanguages
            {
                get { throw new NotImplementedException(); }
            }

            public IList<ProviderListItem> ProviderList
            {
                get { throw new NotImplementedException(); }
            }


            public ILog Log
            {
                get { throw new NotImplementedException(); }
            }


            public IAbstraXDatabaseProxy DatabaseProxy
            {
                get { throw new NotImplementedException(); }
            }


            public IProgrammingLanguage SelectedSourceLanguage
            {
                get { throw new NotImplementedException(); }
            }


            public IBindingsBuilder BindingsBuilder
            {
                get { throw new NotImplementedException(); }
            }


            public bool IncludePublicMemberVariablesAsProperties
            {
                get { throw new NotImplementedException(); }
            }


            Dictionary<string, ICodeProjectTemplate> IDomainHostApplication.ProjectTemplates
            {
                get { throw new NotImplementedException(); }
            }

            Dictionary<string, ICodeItemTemplate> IDomainHostApplication.ItemTemplates
            {
                get { throw new NotImplementedException(); }
            }

            public string RootPath
            {
                get { throw new NotImplementedException(); }
            }

            public string WorkspacePath
            {
                get { throw new NotImplementedException(); }
            }
        }

        static void Main(string[] args)
        {
            var type = typeof(SLConstructorOperation);
            var methodinfo = type.GetMethod("LoadExtension");
            var abstraXExtensionAttribute = methodinfo.GetCustomAttributes(true).Cast<Attribute>().Where(a => a is AbstraXExtensionAttribute).FirstOrDefault();

            //var service = new SLControlProviderService();
            //var indent = 0;

            //service.DomainServiceHostApplication = new Host();

            //var root = service.GetSLControlsRoot();

            //Console.WriteLine(new string(' ', indent) + "Control assemblies");

            //indent += 2;

            //foreach (IElement assembly in root.RootElements.Where(e => !e.DataType.IsAbstract))
            //{

            //    Console.WriteLine(new string(' ', indent) + assembly.Name + "\r\n");

            //    Console.WriteLine(new string(' ', indent) + "Controls:\r\n");

            //    indent += 2;

            //    foreach (IElement control in assembly.ChildElements)
            //    {
            //        Console.WriteLine(new string(' ', indent)      + control.Name);

            //        indent += 2;

            //        Console.WriteLine("\r\n" + new string(' ', indent) + "Elements:\r\n");

            //        foreach (IElement childElem in control.ChildElements)
            //        {
            //            Console.WriteLine(new string(' ', indent) + childElem.Name);
            //        }

            //        Console.WriteLine("\r\n" + new string(' ', indent) + "Attributes:\r\n");

            //        foreach (IAttribute attribute in control.Attributes)
            //        {
            //            Console.WriteLine(new string(' ', indent) + attribute.Name);
            //        }

            //        Console.WriteLine("\r\n");

            //        indent -= 2;
            //    }

            //    indent -= 2;

            //    Console.WriteLine("\r\n");
            //}

            //indent -= 2;

            Console.ReadLine();
        }
    }
}
